<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head></head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>会员注册</title>
<link rel="stylesheet" href="/static/css/bootstrap.min.css" type="text/css" />
<script src="/static/js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="/static/js/bootstrap.min.js" type="text/javascript"></script>
<script src="/static/js/common.js" type="text/javascript"></script>
<!-- 引入自定义css文件 style.css -->
<link rel="stylesheet" href="/static/css/style.css" type="text/css" />

<style>
body {
	margin-top: 20px;
	margin: 0 auto;
}

.carousel-inner .item img {
	width: 100%;
	height: 300px;
}

font {
	color: #3164af;
	font-size: 18px;
	font-weight: normal;
	padding: 0 10px;
}
</style>
</head>
<body>

	<!-- 引入header.jsp -->
	<jsp:include page="/WEB-INF/views/header.jsp"></jsp:include>

	<div class="container"
		style="width: 100%; background: url('/static/images/regist_bg.jpg');">
		<div class="row">
			<div class="col-md-2"></div>
			<div class="col-md-8"
				style="background: #fff; padding: 40px 80px; margin: 30px; border: 7px solid #ccc;">
				<font>会员注册</font>USER REGISTER
				<form class="form-horizontal" style="margin-top: 5px;">
					<div class="form-group">
						<label for="username" class="col-sm-2 control-label">用户名</label>
						<div class="col-sm-6">
							<input type="text" class="form-control" id="username" name="username"
								placeholder="请输入用户名">
						</div>
					</div>
					<div class="form-group">
						<label for="password" class="col-sm-2 control-label">密码</label>
						<div class="col-sm-6">
							<input type="password" class="form-control" id="password" name="password"
								placeholder="请输入密码">
						</div>
					</div>
					<div class="form-group">
						<label for="confirmpwd" class="col-sm-2 control-label">确认密码</label>
						<div class="col-sm-6">
							<input type="password" class="form-control" id="confirmpwd"
								placeholder="请输入确认密码">
						</div>
					</div>
					<div class="form-group">
						<label for="email" class="col-sm-2 control-label">Email</label>
						<div class="col-sm-6">
							<input type="email" class="form-control" id="email" name="email"
								placeholder="Email">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">电话</label>
						<div class="col-sm-6">
							<input type="number" class="form-control" id="phone" name="telephone"
								placeholder="请输入电话">
						</div>
					</div>
					<div class="form-group">
						<label for="question" class="col-sm-2 control-label">密码找回问题</label>
						<div class="col-sm-6">
							<input type="text" class="form-control" id="question" name="name"
								placeholder="密码找回问题">
						</div>
					</div>
					<div class="form-group">
						<label for="answer" class="col-sm-2 control-label">答案</label>
						<div class="col-sm-6">
							<input type="text" class="form-control" id="answer" name="name"
								   placeholder="答案">
						</div>
					</div>

					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<input type="button" width="100" value="注册" name="submit" id="register"
								style="background: url('/static/images/register.gif') no-repeat scroll 0 0 rgba(0, 0, 0, 0); height: 35px; width: 100px; color: white;">
						</div>
					</div>
				</form>
			</div>

			<div class="col-md-2"></div>

		</div>
	</div>

	<!-- 引入footer.jsp -->
	<jsp:include page="/WEB-INF/views/footer.jsp"></jsp:include>

<script>
	$(document).ready(function () {
		$("#register").click(function () {
			if($("#username").val() == ''){
                confirmModel("用户名不能为空！");
                return false;
            }else if($("#password").val() == ''){
                confirmModel("密码不能为空！");
                return false;
			}else if($("#password").val()!=$("#confirmpwd").val()){
                confirmModel("两次输入密码必须相同");
                return false;
            }else if($("#email").val()==''){
                confirmModel("邮箱不能为空！");
                return false;
			}else{
				$.ajax({
					type:"post",
					url:"<c:url value='/user/register'/>",
					async:false, //异步
					data:{
					    username:$("#username").val() ,
						password:$("#password").val() ,
						email:$("#email").val() ,
						phone:$("#phone").val() ,
						question:$("#question").val() ,
						answer:$("#answer").val() ,
					},
					success : function (data) {
					    if(data.status == 0){
                            confirmModel(data.msg);
                            location.href="<c:url value='/user/login'/>";
						}else{
                            confirmModel(data.msg);
						}

                    },
                    error:function () {
                        confirmModel("请求失败");
                    }
				})
			}
        })
    })
</script>

</body>
</html>




